package com.imooc.reader.portal.controller;

import com.imooc.reader.portal.dto.ResponseDTO;
import com.imooc.reader.portal.service.EvaluationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/evaluations")
public class EvaluationController {
    @Resource
    private EvaluationService evaluationService;
    @GetMapping("")
    public ResponseDTO list(Long bookId){
        return new ResponseDTO().put("list",evaluationService.selectByBookId(bookId));
    }

    @PostMapping("")
    public ResponseDTO evaluate(Long memberId , Long bookId , Integer score , String content){
        return new ResponseDTO().put("evaluation",evaluationService.evaluate(memberId,bookId,score,content));
    }
}
